#ifndef _MESSAGEHANDLE_H_
#define _MESSAGEHANDLE_H_

#include <unordered_map>
#include <functional>
#include "chatRoom.h"
#include "stdShared.h"
#include <json-c/json.h>
#include "stdTcpServer.h"

class MessageHandler
{
public:
    using HandleFunction = std::function<void(const std::string &)>;

    /* 构造函数 */
    MessageHandler(const StdTcpSocketPtr &client);
    ~MessageHandler();

public:
    /* 处理信息 */

    void handleMessage(const std::string &msg);

private:
    ChatRoom m_chatroom;
    /* 函数映射表 */
    std::unordered_map<int, HandleFunction> m_handles;
};

#endif // _MESSAGEHANDLE_H_
